1 using UnityEngine;
2 using
System.Collections;
3
4
5 ///
<summary>
6 ///
TweenFlows are used for creating a chain of Tweens via the append/prepend methods. You can also get timeline
7 ///
like control by inserting Tweens and setting them to start at a specific time. Note that TweenFlows do not
8 ///
honor the delays set within regular Tweens. Use the append/prependDelay method to add any required delays
9 ///
</summary>
10 public
class GoTweenFlow : AbstractGoTweenCollection
11 {
12     
public GoTweenFlow() : this( new GoTweenCollectionConfig() ) {}
13
14     
public GoTweenFlow( GoTweenCollectionConfig config ) : base( config ) {}
15
16
17     
#region internal Flow management
18     
19     ///
<summary>
20     ///
the item being added already has a start time so no extra parameter is needed
21     ///
</summary>
22     
private void insert( TweenFlowItem item )
23     {
24         
// early out for invalid items
25         
if( item.tween != null && !item.tween.isValid() )
26             
return;
27         
28         
if( float.IsInfinity( item.duration ) )
29         {
30             Debug.LogError(
"adding a Tween with infinite iterations to a TweenFlow is not permitted" );
31             
return;
32         }
33         
34         
if( item.tween != null )
35         {
36             
if (item.tween.isReversed != isReversed)
37             {
38                 Debug.LogError(
"adding a Tween that doesn't match the isReversed property of the TweenFlow is not permitted." );
39                 
return;
40             }
41
42             
// ensure the tween isnt already live
43             Go.removeTween(item.tween);
44
45             
// ensure that the item is marked to play.
46             item.tween.play();
47         }
48
49         
// add the item then sort based on startTimes
50         _tweenFlows.Add( item );
51         _tweenFlows.Sort( ( x, y ) =>
52         {
53             
return x.startTime.CompareTo( y.startTime );
54         } );
55         
56         duration = Mathf.Max( item.startTime + item.duration, duration );
57
58         
if (iterations < 0)
59             totalDuration =
float.PositiveInfinity;
60         
else
61             totalDuration = duration * iterations;
62     }
63     
64     
#endregion
65     
66     
67     
#region Flow management
68     
69     ///
<summary>
70     ///
inserts a Tween and sets it to start at the given startTime
71     ///
</summary>
72     
public GoTweenFlow insert( float startTime, AbstractGoTween tween )
73     {
74         
var item = new TweenFlowItem( startTime, tween );
75         insert( item );
76         
77         
return this;
78     }
79     
80     
#endregion
81     
82
83 }



Trò chơi Angry Birds trong UNITY Engine 31.676 lượt xem

Gõ tìm kiếm nhanh...